package com.oscarmovie;

import tt.util.IOUtils;
import weibo4j.Timeline;
import weibo4j.Weibo;
import weibo4j.http.ImageItem;
import weibo4j.model.Status;
import weibo4j.model.WeiboException;

public class WeiboUtils {
	
	public static void sendWeibo(Weibo weibo, String text, String imageUrl){
		Timeline tm = new Timeline(weibo);
		try {
			byte[] image= IOUtils.readHttpUrlAsByteArray(imageUrl);
			ImageItem pic=new ImageItem("pic",image);
			Status status=tm.UploadStatus(text, pic);
		} catch (WeiboException e) {
			e.printStackTrace();
		}
	}
	
	public static void sendWeibo(Weibo weibo, String text){
		Timeline tm = new Timeline(weibo);
		try {
			Status status=tm.UpdateStatus(text);
		} catch (WeiboException e) {
			e.printStackTrace();
		}
	}
	
}
